<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>props</title>
</head>
<body>
<div id="props_demo">
    <props_demo-component :init-count="1"></props_demo-component>
</div>
<div id="props_demo1">
    <props_demo-component1 :width="10"></props_demo-component1>
</div>
<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
<script>
    Vue.component('props_demo-component', {
        props: ['initCount'],
        template: '<div>{{count}}</div>',
        data: function () {
            return {
                count: this.initCount
            }
        }
    })
    new Vue({
        el: '#props_demo'
    })
    Vue.component('props_demo-component1', {
        props: ['width'],
        template: '<div :style="style">{{style}}</div>',
        //使用计算属性
        computed: {
            style: function () {
                return {
                    width: this.width + 'px'
                }

            }
        }
    })
    new Vue({
        el: '#props_demo1'
    })
</script>
</body>
</html>